﻿Public Class Projekt
    Inherits Base

    Public name As String

    Public kunde As Kunde

    Public tasks As New List(Of Task)

    Public Function getKosten() As Double
        Dim kosten As Double = 0
        For Each task As Task In Me.tasks
            For Each zeitrapport As Zeitrapport In task.zeitrapporte
                kosten += CDbl(zeitrapport.mitarbeiter.stundenansatz) * CDbl(zeitrapport.anzahlMinuten) / CDbl(60)
            Next
        Next
        Return kosten
    End Function

    Public Function getFormatedKosten() As String
        Return FormatCurrency(getKosten())
    End Function

    Public Overrides Sub validate()
        If isEmptyString(Me.name) Then
            Throw New Exception("Name ist leer.")
        End If
        If kunde Is Nothing Then
            Throw New Exception("Kein Kunde ist gesetzt.")
        End If
    End Sub
End Class
